<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
	</head>

	<body>
		<form class="layui-form fenzu_form" action="" method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">等级名称</label>
				<div class="layui-input-block">
					<input type="text" style="width: 150px;" name="name" value="" class="layui-input" required lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">需消费次数</label>
				<div class="layui-input-block">
					<input type="text" style="width: 150px;" name="nums" value="" class="layui-input" required lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item huiyuan_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" type="button" id="tijiao" lay-submit lay-filter="submit_from">保存</button>
				</div>
			</div>
		</form>
		<script>
			//Demo
			layui.use('form', function() {
				var form = layui.form;
				//监听表单提交
				form.on('submit(submit_from)', function(data){
					tijiao();
		  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
				});
			});
		</script>
	</body>

</html>
<script>
	$(".layui-input-block input[type='text']").change(function() {
		var value = $(this).data("value");
		if(value) {
			$("#lay_" + value).val($(this).val() + "次");
		}

	})

	function  tijiao(){
		$.ajax({
			type: 'POST',
			data: {
				id	   : $('#id').val(),
				number1: $("#number1").val(),
				number2: $("#number2").val(),
				number3: $("#number3").val(),
				number4: $("#number4").val(),
				number5: $("#number5").val()
			},
			url: "{:url('accounts/fenzu_setting')}",
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					}, function() {
						window.parent.location.reload();
					});
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}

			}
		});
	});
</script>